package com.sancorseguros.nova.selenium.pageobject;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

import com.sancorseguros.nova.selenium.config.StaticSelenium;


public class LoginNovaPage extends AbstractPage {

	private static final long serialVersionUID = 4823642494885660380L;

	private WebDriver driver;
	
    public LoginNovaPage(WebDriver driver) throws InterruptedException {  
        super();  
        this.setDriver(driver);
        this.setTitle(StaticSelenium.TITLE_LOGIN_NOVA);
        this.waitForTitle(StaticSelenium.TITLE_LOGIN_NOVA, driver.getTitle());
	}
	
	public void doLoginAs(WebDriver driver) throws InterruptedException {
		Thread.sleep(1000);
		driver.findElement(By.id("Text1")).sendKeys(StaticSelenium.USER_NAME);
		driver.findElement(By.id("Password1")).sendKeys(StaticSelenium.USER_PASS);
	}	
	
	public NovaMenuPage goToNovaMenu(WebDriver driver) throws InterruptedException {
		driver.findElement(By.id("Submit1")).click();
		return new NovaMenuPage(this.getDriver());
	}
	
	@Override
	public void validatePage() {
    	assertTrue(StaticSelenium.INVALID_PAGE, this.verifyPage(this.getDriver(), StaticSelenium.TITLE_LOGIN_NOVA));
    }

	public WebDriver getDriver() {
		return driver;
	}

	public void setDriver(WebDriver driver) {
		this.driver = driver;
	}


}

